// import http from '../http';
import * as qiniu from 'qiniu-js';

class Qiniu {

	config = {}
	
	putExtra = {}

    getToken = (dir) => {
        const exp = 3600;
        const params = { exp, dir };
        return http.get('resource/qiniu/token', { params });
      
    }

    // 上传至7牛服务器
    upload(file, key, token, fn) {
        let ob = qiniu.upload(file, key, token, this.putExtra, this.config);
        let sub = ob.subscribe(fn);
        return sub;

    }

} 

export default new Qiniu();